//for order.html
//var loginStatus = getL();

//校验收件地址是否是虚拟地址
function checkRecVirtualAddress(index){
	//判断是否是“自取”,门店代码
	var form = $("#recForm" + index);
	var rcityIdObj = form.find("input[@type=text][name=rcityId" + index + "]");
	var rcityId = rcityIdObj.val();
	var rcityNameObj = form.find("input[@type=text][name=rcityName]");
	var rcityName = rcityNameObj.val();
	var rprovinceNameObj = form.find("input[@type=text][name=rprovinceName]");
	var rprovinceName = rprovinceNameObj.val();
	var r_addressCodeObj = form.find("input[@type=text][name=raddress]");
	var r_addressCode = r_addressCodeObj.val();
	//在线下单，个人收件地址只有一个收件人数据
	var flag=false;
	if($("#selfPickUpChx").attr("checked")=='checked' && (/^[0-9]*$/.test(r_addressCode)) && (r_addressCode !="") && ("中国"==$("#nation").val())){
	  //获取门店地址信息
		var params = {
				'provinceName':espaceQuote(rprovinceName),
				'cityName':espaceQuote(rcityName),
				'cityId':rcityId,
				'addressCode':r_addressCode
		};
		syncCallService('/service/order/check/heiguest/address', "post", "json", params, function(data) {
			flag=data;
			if(data == false) {
				sfAlert("收无忧（即虚拟地址）编码错误，请重新输入");
			} 
			});
		return flag;
	}/*else if($("#hg_selfPick").attr("checked")=='checked' && !(/^[0-9]*$/.test(r_addressCode))){
		sfAlert("填写收无忧（即虚拟地址）时，收无忧（即虚拟地址）编码不正确");
		return;
	}*/else if(( $("#selfPickUpChx").attr("checked") == undefined || $("#selfPickUpChx").attr("checked") !='checked') && (r_addressCode !="") && (/^[0-9]*$/.test(r_addressCode)) && ("中国"==$("#nation").val())){
		sfAlert("填写收无忧（即虚拟地址）编码时，一定要勾选“自取”");
		return false;
	}else{
		if($.trim(r_addressCode) =="") {
			$("#r_address").val(r_addressCodeObj.attr("tip")); 
		}
		return true;
	}
}

//校验寄件地址是否是虚拟地址
function checkSendVirtualAddress(){
	//判断是否是“自取”,门店代码
	var s_addressCode=$("#s_address").val();
	var sprovinceName=$('#s_provinceName').val();
	var scityName=$('#s_cityName').val();
	var scityId=$('#s_cityId').val();
	//在线下单，个人收件地址只有一个收件人数据
	var flag=false;
	if($("#heike").attr("checked")=='checked' && (/^[0-9]*$/.test(s_addressCode)) && (s_addressCode !="") && ("中国"==$("#nation").val())){
	  //获取门店地址信息
		var params = {
				'provinceName':espaceQuote(sprovinceName),
				'cityName':espaceQuote(scityName),
				'cityId':scityId,
				'addressCode':s_addressCode
		};
		syncCallService('/service/order/check/heiguest/address', "post", "json", params, function(data) {
			flag=data;
			if(data == false) {
				sfAlert("收无忧（即虚拟地址）编码错误，请重新输入");
			}
			});
		return flag;
	}/*else if($("#heike").attr("checked")=='checked' && !(/^[0-9]*$/.test(s_addressCode))){
		sfAlert("填写收无忧（即虚拟地址）时，收无忧（即虚拟地址）编码不正确");
		return;
	}*/else if(($("#heike").attr("checked") == undefined || $("#heike").attr("checked") != 'checked') && (s_addressCode !="") && (/^[0-9]*$/.test(s_addressCode)) && ("中国"==$("#nation").val())){
		sfAlert("填写收无忧（即虚拟地址）编码时，一定要选取“自寄”");
		return false;
	}else{
		return true;
	}
}


function checkDetailVirtualAddress(index){
	//判断是否是“自取”,门店代码
	var receiverCityId = $("#receiverCityId"+index).val();
	var receiverCityName = $("#receiverCityName"+index).val();
	var receiverProvinceName = $("#receiverProvinceName"+index).val();
	var receiverAddress = $("#receiverAddress"+index).val();
	//在线下单，个人收件地址只有一个收件人数据
	var flag=false;
	if($('#selfPickUpChx'+index).attr("checked")=='checked' && (/^[0-9]*$/.test(receiverAddress)) && (receiverAddress !="")){
	  //获取门店地址信息
		var params = {
				'provinceName':espaceQuote(receiverProvinceName),
				'cityName':espaceQuote(receiverCityName),
				'cityId':receiverCityId,
				'addressCode':receiverAddress
		};
		syncCallService('/service/order/check/heiguest/address', "post", "json", params, function(data) {
			flag=data;
			if(data == false) {
				sfAlert("收无忧（即虚拟地址）编码错误，请重新输入");
			} 
			});
		return flag;
	}/*else if($("#hg_selfPick").attr("checked")=='checked' && !(/^[0-9]*$/.test(r_addressCode))){
		sfAlert("填写收无忧（即虚拟地址）时，收无忧（即虚拟地址）编码不正确");
		return;
	}*/else if(( $('#selfPickUpChx'+index).attr("checked") == undefined || $('#selfPickUpChx'+index).attr("checked") !='checked') && (receiverAddress !="") && (/^[0-9]*$/.test(receiverAddress))){
		sfAlert("填写收无忧（即虚拟地址）编码时，一定要勾选“自取”");
		return false;
	}else{
		return true;
	}
}